package Tank51;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

//import static com.sun.java.accessibility.util.AWTEventMonitor.addWindowListener;

public class TankGame {
    public static void main(String[] args) {

        start();


    }

    public static void start() {


        boolean exit = false;
        showHeader();
        showMenu();
        showFooter();

        Scanner scanner = new Scanner(System.in);

        while(!exit){
            int choice = scanner.nextInt();
            switch(choice){
                case 1:
                    startGame();
                    System.out.println("鍚姩鍥惧舰鐣岄�?...");

                    GameWindow myWindow = new GameWindow();
                    myWindow.startFrame();
                    break;
                case 2:
                    choosePass();
                    showMenu();
                    break;
                case 3:
                    choosePlayer();
                    showMenu();
                    break;
                case 4:
                    try {
                        endGame();
                        exit = true;
                    } catch (Exception e) {
                        e.printStackTrace();
                        e.toString();
                    }

                    showMenu();
                    break;
            }
        }



    }

    public static void endGame() throws Exception{
        Scanner scanner = new Scanner(System.in);
        System.out.println("娓告垙缁撴潫");
        System.out.println("璇疯緭鍏ョ帺瀹跺悕绉�?");
        String name = scanner.nextLine();
        System.out.println("璇疯緭鍏ョ帺瀹跺勾榫�?");
        int age = 0;
        try {
            age = scanner.nextInt();
        }catch(Exception e){
            System.out.println("璇疯緭鍏ユ纭殑骞撮緞");
            e.printStackTrace();
        }
        if(age <= 0 | age > 100){
            throw new InputException(name,age);
        }
    }

    public  static void choosePlayer() {
        System.out.println("璇烽�鎷╃帺瀹讹�?");
        Scanner scanner = new Scanner(System.in);
        System.out.println("1銆�.1p");
        System.out.println("2銆�.2p");
        int player = scanner.nextInt();
    }

    public static void choosePass() {
        System.out.println("璇烽�鎷╁叧鍗★�?");
        Scanner scanner = new Scanner(System.in);
        System.out.println("1銆佺涓�叧");
        System.out.println("2銆佺浜屽叧");
        System.out.println("3銆佺涓夊叧");
        int pass = scanner.nextInt();
    }

    public static void startGame() {
        System.out.println("娓告垙寮�");
    }

    public static void showFooter() {
        System.out.println("***************************************************************");
        System.out.println("娌冲寳鍖栧伐鍖昏嵂鑱屼笟鎶�湳�?﹂櫌");
    }

    public static void showHeader() {
        System.out.println("娆㈣繋杩涘叆鍧﹀厠澶ф垬娓告垙");
        System.out.println("***************************************************************");
    }

    public  static void showMenu() {
        System.out.println("1銆佸紑濮嬫父鎴�");
        System.out.println("2銆佸叧鍗￠�鎷�");
        System.out.println("3銆佺帺�?堕�鎷�");
        System.out.println("4銆侀�鍑烘父鎴�");
        System.out.println("璇烽�鎷╋紙1 ~ 4锛�");
    }


}
